package com.spic.business.mountguard.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.spic.common.log.annotation.Log;
import com.spic.common.log.enums.BusinessType;
import com.spic.common.security.annotation.PreAuthorize;
import com.spic.business.mountguard.domain.MountSign;
import com.spic.business.mountguard.service.IMountSignService;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.page.TableDataInfo;

/**
 * 上岗签到表Controller
 * 
 * @author spic
 * @date 2021-12-05
 */
@RestController
@RequestMapping("/mountguard/sign")
public class MountSignController extends BaseController
{
    @Autowired
    private IMountSignService mountSignService;

    /**
     * 查询上岗签到表列表
     */
    @PreAuthorize(hasPermi = "business/mountguard:sign:list")
    @GetMapping("/list")
    public TableDataInfo list(MountSign mountSign)
    {
        startPage();
        List<MountSign> list = mountSignService.selectMountSignList(mountSign);
        return getDataTable(list);
    }

    /**
     * 导出上岗签到表列表
     */
    @PreAuthorize(hasPermi = "business/mountguard:sign:export")
    @Log(title = "上岗签到表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MountSign mountSign) throws IOException
    {
        List<MountSign> list = mountSignService.selectMountSignList(mountSign);
        ExcelUtil<MountSign> util = new ExcelUtil<MountSign>(MountSign.class);
        util.exportExcel(response, list, "上岗签到表数据");
    }

    /**
     * 获取上岗签到表详细信息
     */
    @PreAuthorize(hasPermi = "business/mountguard:sign:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(mountSignService.selectMountSignById(id));
    }

    /**
     * 新增上岗签到表
     */
    @PreAuthorize(hasPermi = "business/mountguard:sign:add")
    @Log(title = "上岗签到表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MountSign mountSign)
    {
        return toAjax(mountSignService.insertMountSign(mountSign));
    }

    /**
     * 修改上岗签到表
     */
    @PreAuthorize(hasPermi = "business/mountguard:sign:edit")
    @Log(title = "上岗签到表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MountSign mountSign)
    {
        return toAjax(mountSignService.updateMountSign(mountSign));
    }

    /**
     * 删除上岗签到表
     */
    @PreAuthorize(hasPermi = "business/mountguard:sign:remove")
    @Log(title = "上岗签到表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(mountSignService.deleteMountSignByIds(ids));
    }
}
